/*
 *  POJ1426: Find The Multiple
 *
 *  Note: Array Complete Binary Tree
 */

/*-------- Includes --------*/
#include <iostream>

using namespace std;

/*-------- Types --------*/

/*-------- Global Variables --------*/
int rm[524287]; // 524286 + 1

/*-------- Function Prototypes --------*/

/*-------- Main Function --------*/
int main(int argc, char const *argv[])
{
    int n;

    while (cin >> n && n) {
        // special case: n=1
        if (n == 1) {cout << "1" << endl; continue;}

        int k    = 1;
        int rten = 10 % n;

        // first element
        rm[k] = 1;

        // special version of BFS
        for (k = 2; rm[k - 1] != 0; k++)
            rm[k] = (rm[k / 2] * rten + k % 2) % n;

        k--;

        // generate m
        int l = 0;
        while (k > 0) {
            if (k % 2) rm[l++] = 1;
            else       rm[l++] = 0;

            k /= 2;
        }

        // print
        for (int i = l - 1; i >= 0; i--) cout << rm[i];
        cout << endl;
    }

    return 0;
}

/*-------- Functions --------*/

